#include<iostream>

using std::cout;
using std::endl;

class Point;
class Complex
{
public:
    Complex(int a,int b);
    Complex(const Point& a);
    Complex& operator=(const Point&a);
    void print();
    friend
        class Point;
private:
    int _real;
    int _image;
};
class Point
{
public:
    Point(int a ,int b);
    //第2种
    operator Complex()
    {
        Complex a(_x,_y);
        return a;
    }
    friend
        class Complex;
private:
        int _x;
        int _y;
};
Complex::Complex(int a,int b)
        :_real(a)
         ,_image(b)
    {
    }
 void Complex::print()
    {
        cout<<"("<<_real<<"+"<<_image<<"i"<<")"<<endl;
    }

Point::Point(int a ,int b)
    :_x(a)
     ,_y(b)
    {
    }
    //第一种
Complex::Complex(const Point& a)
:_real(a._x)
    ,_image(a._y)
{}
    Complex& Complex::operator=(const Point&a)
{
    _real=a._x;
    _image=a._y;
    return *this;
}
int main(void)
{
    Point pt(3,9);
    Complex cx(4,6);
    cx = pt;
    cx.print();
}
